INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${NEL_INCLUDE_DIR})

FILE(GLOB SRC src/*.cpp src/*.h resources/*.rc)

FILE(GLOB CLIENT_CONFIG_HDR src/*.h)
FILE(GLOB CLIENT_CONFIG_UIS ui/*.ui)
FILE(GLOB CLIENT_CONFIG_BASE_TRANS translations/qtbase_*.ts)
FILE(GLOB CLIENT_CONFIG_TRANS translations/ryzom_configuration_*.ts)

CONFIGURE_FILE(translations/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc COPYONLY)
SET(CLIENT_CONFIG_RCS resources/resources.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc )

IF(WITH_QT)
  INCLUDE_DIRECTORIES(${QT_INCLUDES})
  INCLUDE(${QT_USE_FILE})

  QT4_ADD_TRANSLATION(CLIENT_CONFIG_QM ${CLIENT_CONFIG_TRANS})
  QT4_ADD_RESOURCES(CLIENT_CONFIG_RC_SRCS ${CLIENT_CONFIG_RCS})
  QT4_WRAP_CPP(CLIENT_CONFIG_MOC_SRC ${CLIENT_CONFIG_HDR})
  QT4_WRAP_UI(CLIENT_CONFIG_UI_HDRS ${CLIENT_CONFIG_UIS})

  ADD_DEFINITIONS(${QT_DEFINITIONS})
ELSE()
#  uncomment this line if you want to update original translations
#  QT5_CREATE_TRANSLATION(CLIENT_CONFIG_QM ${CLIENT_CONFIG_UIS} ${SRC} ${CLIENT_CONFIG_TRANS} OPTIONS -I ${CMAKE_CURRENT_SOURCE_DIR})
  QT5_ADD_TRANSLATION(CLIENT_CONFIG_QM ${CLIENT_CONFIG_TRANS} ${CLIENT_CONFIG_BASE_TRANS})
  QT5_ADD_RESOURCES(CLIENT_CONFIG_RC_SRCS ${CLIENT_CONFIG_RCS})
  QT5_WRAP_CPP(CLIENT_CONFIG_MOC_SRC ${CLIENT_CONFIG_HDR})
  QT5_WRAP_UI(CLIENT_CONFIG_UI_HDRS ${CLIENT_CONFIG_UIS})
ENDIF()

IF(WITH_RYZOM_STEAM)
  ADD_DEFINITIONS(-DRZ_USE_STEAM)
ENDIF()

SOURCE_GROUP("Resources" FILES ${CLIENT_CONFIG_RCS})
SOURCE_GROUP("Forms" FILES ${CLIENT_CONFIG_UIS})
SOURCE_GROUP("Generated Files" FILES ${CLIENT_CONFIG_UI_HDRS} ${CLIENT_CONFIG_MOC_SRC})
SOURCE_GROUP("Translation Files" FILES ${CLIENT_CONFIG_TRANS} ${CLIENT_CONFIG_BASE_TRANS})

ADD_EXECUTABLE(ryzom_configuration_qt WIN32 ${SRC} ${CLIENT_CONFIG_MOC_SRC} ${CLIENT_CONFIG_UI_HDRS} ${CLIENT_CONFIG_RC_SRCS} ${CLIENT_CONFIG_TRANS} ${CLIENT_CONFIG_BASE_TRANS} ${CLIENT_CONFIG_QM})
NL_DEFAULT_PROPS(ryzom_configuration_qt "Ryzom, Tools: Ryzom Configuration Qt" )
NL_ADD_RUNTIME_FLAGS( ryzom_configuration_qt )
NL_ADD_LIB_SUFFIX( ryzom_configuration_qt )
TARGET_LINK_LIBRARIES( ryzom_configuration_qt nelmisc nel3d ${QT_LIBRARIES} ${OPENGL_gl_LIBRARY})

IF(WITH_PCH)
  ADD_NATIVE_PRECOMPILED_HEADER(ryzom_configuration_qt ${CMAKE_CURRENT_SOURCE_DIR}/src/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/src/stdpch.cpp)
ENDIF()

INSTALL(TARGETS ryzom_configuration_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client)
